//
//  UIBarButtonItem+extention.swift
//  SUNweibo
//
//  Created by sighting on 16/8/22.
//  Copyright © 2016年 sighting. All rights reserved.
//

import UIKit

extension UIBarButtonItem{

    // MARK:便利方法
    convenience init(title:String,target: AnyObject?,action: Selector,isBack:Bool = false) {
        
        let bnt = UIButton()
        if isBack {
            let name = "navigationbar_back_withtext"
            bnt.setImage(UIImage(named:name), for: .normal)
            bnt.setImage(UIImage(named:"\(name)_highlighted"), for: .highlighted)
        }
        bnt.setTitle(title, for: .normal)
        bnt.setTitleColor(UIColor.darkGray(), for: .normal)
        bnt.setTitleColor(UIColor.orange(), for: .highlighted)
        bnt.addTarget(target, action:action, for: .touchUpInside)
        bnt.sizeToFit()
        
       self.init(customView: bnt)
    }

}
